
#include "URI.h"
#include "HTTP.h"

#include "LWP/Simple.h"
#include "LWP/UserAgent.h"

#include <iostream>
#include <string>
#include <map>

using namespace std;

using URI::URL;


int main()
{
	
	URL url("localhost/query");
	cout<<url.get_url()<<endl;
	cout<<url.get_host()<<endl;
	cout<<url.get_file()<<endl;
	cout<<url.to_string()<<endl;
	cout<<endl;


	map<string, string> form;
	form["a"]="b";
	URL posturl("lilybbs.net/query");
	posturl.query_form(form);
	cout<<posturl.get_url()<<endl;
	cout<<posturl.get_host()<<endl;
	cout<<posturl.get_file()<<endl;
	cout<<posturl.to_string()<<endl;
	cout<<endl;

	HTTP::HttpForm hform;
	hform.add_data("user", "me");
	hform.add_data("password", "i&u");
	URL http_url("my.space.com/search");
	http_url.query_form(form);
	http_url.query_form(hform);
	string full_url = http_url;
	cout<<full_url<<endl;
	http_url.query_form("pass", "word", "user", "name");
	cout<<http_url.to_string();
	cout<<endl;

	cout<<URI::encode_data(hform)<<endl;
	
	return 0;
}

